﻿#region

using System;
using System.Drawing;
using System.Drawing.Drawing2D;

#endregion

namespace GGEditor.API.Utility.Forms
{
    public class GraphicsStateFrame : IDisposable
    {
        private readonly Graphics g;
        private GraphicsState gstate;

        public GraphicsStateFrame(Graphics g)
        {
            this.g = Contract.NotNull(g, "g");
            try {
                gstate = g.Save();
            } catch {}
        }

        #region IDisposable Members

        public void Dispose()
        {
            try {
                g.Restore(gstate);
            } catch {}
        }

        #endregion
    }
}